'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-10-27 20:45:36
'''
#
# @lc app=leetcode.cn id=121 lang=python3
#
# [121] 买卖股票的最佳时机
#

# @lc code=start
class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        from sys import maxsize
        m = maxsize
        ans = 0
        for p in prices:
            ans = max(ans, p-m)
            m = min(p, m)
        return ans
# @lc code=end

